<?php
use yii\helpers\Url;
use yii\web\View;
use app\assets\UsersAsset;
UsersAsset::register($this);
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  \Yii::t('common', 'Assets'),
  \Yii::t('common', 'User')
];
$jsMsgs = $this->context->loadJsMsgs([
  'table',
  'dialog',
  'listOp',
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="page-header">
  <h1>
    <?=\Yii::t('common', 'User')?>
    <small><?=\Yii::t('user', 'User List')?></small>
    <div class="btn-group btn-group-sm pull-right" role="group" aria-label="...">
      <a href="<?php echo Url::to(['users/new-user']); ?>" class="btn btn-success" data-loading-text="<i class='fa fa-spinner fa-spin'></i> <?=\Yii::t('common', 'Loading')?>..." id="new-operate-btn">
        <i class="fa fa-user-plus"></i>
        <?=\Yii::t('user', 'New User')?>
      </a>
    </div>
  </h1>
</div>
<div class="panel panel-default">
  <div class="panel-heading"> 
    <i class="fa fa-table"></i>
    <?=\Yii::t('user', 'User List')?>
    <ul class="list-inline list-unstyled pull-right">
      <li>
        <a class="data-table-refresh" href="#" title="<?=\Yii::t('common', 'Click to refresh data')?>">
          <i class="fa fa-refresh"></i>
        </a>
      </li>
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body pos-r">
    <div id="list-loading-wrap" class="local-loading-wrap"></div>
    <div class="table-responsive">
      <table class="table table-hover table-striped table-bordered table-condensed" id="data-table" data-tag="vm-adserver.users-list">
        <thead class="heading">
          <tr>
            <th data-resizable-column-id="id" data-search="on" data-filter="on">ID</th>
            <th data-resizable-column-id="name" data-search="on" data-filter="on"><?=\Yii::t('user', 'Name')?></th>
            <th data-resizable-column-id="type" data-search="on" data-filter="on"><?=\Yii::t('user', 'Type')?></th>
            <th data-resizable-column-id="email" data-search="on" data-filter="on"><?=\Yii::t('user', 'Email')?></th>
            <!-- <th>角色</th> -->
            <th data-resizable-column-id="resource" data-search="on" data-filter="on"><?=\Yii::t('user', 'Resource')?></th>
            <th data-resizable-column-id="status" data-search="on" data-filter="on"><?=\Yii::t('user', 'Status')?></th>
            <th data-resizable-column-id="lastModifiedDate" data-search="on" data-filter="on"><?=\Yii::t('user', 'Update Time')?></th>
            <th data-resizable-column-id="operate" data-filter="on"><?=\Yii::t('user', 'Actions')?></th>
          </tr>
        </thead>
        <tbody>
          <tr role="row">
            <td class="text-center dataTables_empty" colspan="8"><?=\Yii::t('site', 'No Records')?></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
<div id="extra-container"></div>
<div class="modal fade" id="reset-pwd-modal">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header btn-danger">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title"><?=\Yii::t('user', 'Reset Password')?></h4>
      </div>
      <div class="modal-body">
        <p class="text-center text-danger"><i class="fa fa-exclamation-triangle"></i> <?=\Yii::t('user', 'Are you sure to reset password?')?></p>
        <!-- <p class="text-center help-block">密码默认为111111。</p> -->
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><?=\Yii::t('common', 'Close')?></button>
        <button type="button" class="btn btn-danger" id="reset-confirm-operate"><?=\Yii::t('common', 'Sure')?></button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>
<?php
  // $dataUrl = Yii::getAlias('@web').'/response/users/usersDataList.php';
  $dataUrl = Url::to(['get-users']);
  $dataEditUrl = Url::to(['user-edit']);
  $dataResetPwdUrl = Url::to(['list-operate-handle']);
  $this->registerJs("VAM.setVar('USERS_DATA_LIST','$dataUrl');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_EDIT_URL','$dataEditUrl');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_RESET_PWD_OP_URL','$dataResetPwdUrl');", View::POS_HEAD);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/users/userList.js"]);
  });
</script>